package com.wf.LeetCode;

/**
 * @author mpk
 * @since 2024/6/10 13:49:35
 */

/*1480. 一维数组的动态和
        简单
        相关标签
        相关企业
        提示
        给你一个数组 nums 。数组「动态和」的计算公式为：runningSum[i] = sum(nums[0]…nums[i]) 。

        请返回 nums 的动态和。*/
public class Solution {
    public static void main(String[] args) {

        int [] nums = {1,2,3,4};
        for (int i : runningSum(nums)) {

            System.out.println(i);
        }

    }

    public static int[] runningSum(int[] nums) {


        int sum = 0;
        int[] runningSum = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {


            sum += nums[i];
            runningSum[i] = sum;

        }


        return runningSum;

    }

}
